package org.gd.hellojaxb.privat24.cardlist;

import org.gd.hellojaxb.adapters.DateAdaptersFactory;
import org.gd.hellojaxb.utils.Marshall;
import org.gd.hellojaxb.utils.MarshallProperties;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.Date;

@XmlRootElement(name = "rating")
@XmlAccessorType(XmlAccessType.NONE)
public class SRating {

    @XmlAttribute(name = "num")
    private String number;
    @XmlAttribute(name = "date")
    @XmlJavaTypeAdapter(DateAdaptersFactory.DateTimeFormat.class)
    private Date date;
    @XmlAttribute(name = "rate")
    private int rate;
    private Double amt;

    public SRating() {
    }

    public String getNumber() {
        return number;
    }

    public SRating setNumber(String number) {
        this.number = number;
        return this;
    }

    public Date getDate() {
        return date;
    }

    public SRating setDate(Date date) {
        this.date = date;
        return this;
    }

    public int getRate() {
        return rate;
    }

    public SRating setRate(int rate) {
        this.rate = rate;
        return this;
    }

    @SuppressWarnings("unused")
    public Double getAmt() {
        return amt;
    }

    @SuppressWarnings("unused")
    public SRating setAmt(Double amt) {
        this.amt = amt;
        return this;
    }

    @Override
    public String toString() {
        try {
            return Marshall.getInstance().marshal(this, MarshallProperties.WITHOUT_XML_HEADER);
        } catch (Exception e) {
            return super.toString();
        }
    }
}
